import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    debugShowCheckedModeBanner: false,
    title: '网页标题',
    home: Scaffold(
      appBar: AppBar(
        title: Text('头部标题'),
        titleTextStyle: TextStyle(
            color: const Color.fromARGB(255, 63, 61, 61),
            fontSize: 15,
            fontWeight: FontWeight.bold),
        centerTitle: true,
        backgroundColor: const Color.fromARGB(255, 184, 206, 17),
        leading: Icon(
          Icons.arrow_back_ios,
          color: const Color.fromARGB(255, 60, 59, 58),
        ),
        actions: [
          Icon(Icons.menu, color: const Color.fromARGB(255, 68, 67, 67))
        ],
      ),
      body: MyBody(),
      floatingActionButton: Icon(Icons.add),
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.wechat),
            label: '微信',
            activeIcon: Icon(
              Icons.wechat_outlined,
              color: Colors.lightGreenAccent,
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.camera_alt_rounded),
            label: '拍照',
            activeIcon: Icon(
              Icons.camera_alt_outlined,
              color: Colors.lightGreenAccent,
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.weekend_outlined),
            label: '沙发',
            activeIcon: Icon(
              Icons.weekend_outlined,
              color: Colors.lightGreenAccent,
            ),
          ),
        ],
      ),
    ),
  ));
}

class MyBody extends StatefulWidget {
  MyBody({Key? key}) : super(key: key);

  @override
  _MainState createState() {
    print('创建');
    return _MainState();
  }
}

class _MainState extends State<MyBody> {
  int age = 20;

  @override
  void initState() {
    super.initState();
    print('初始化');
  }

  @override
  Widget build(BuildContext context) {
    print('构建UI');
    return Center(
      child: TextButton(
          onPressed: () {
            setState(() {
              age++;
            });
          },
          child: Text('今年$age岁了')),
    );
  }
}
